package com.yzh.dxpro.p3.sta;
import java.io.IOException;
import java.util.Iterator;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import com.yzh.dxpro.p4.utils.TProperties;

public class DxStaOneReducer extends Reducer<Text,IntWritable,NullWritable,Text>{
	protected void reduce(Text key, Iterable<IntWritable> values,
			Reducer<Text, IntWritable, NullWritable, Text>.Context context) 
			throws IOException, InterruptedException {
		//key060581000000000000|513047538993  values: [1,1,1,1]
		System.out.println("~~~~reducer1");
		Iterator<IntWritable> it = values.iterator();//迭代器
		int sum=0;
		while(it.hasNext()) {
			IntWritable temp= it.next();
			int i = temp.get();
			sum=sum+i;
		}
		String ovalue = key.toString()+TProperties.getValue("outfilesplit")+sum;
		context.write(NullWritable.get(), new Text(ovalue));
	}

}
